/* eslint-disable react/jsx-no-bind */
import { h, Component } from 'preact';
import classNames from 'classnames';
import TabContext from './TabContext';

class NavTab extends Component {

	constructor(props) {
		super(props);
		this.tab = props.tab;
	}

	componentDidMount() {
	}

	render({ title, tab, children, ...other },state) {

		return (
			<TabContext.Consumer>
				{
					({ active, onChange }) => (<li onClick={_ => { onChange(tab); }} className={classNames('nav-item')}>
						<a href="javascript:;" class={classNames('nav-link',{ active: active===this.tab })}>{title}</a>
					</li>)
				}
			</TabContext.Consumer>
		);
	}
}

NavTab.propTypes = {

};

NavTab.defaultProps = {
	onChange: () => { },
	active: 1
};

export default NavTab;
